package com.bosicloud.cmb.ibp.aws.adapter.controller;

import com.amazonaws.services.ecs.model.Service;
import com.bosicloud.cmb.ibp.aws.adapter.commom.constant.UrlDefine;
import com.bosicloud.cmb.ibp.aws.adapter.commom.dto.DeployeAppParamDTO;
import com.bosicloud.cmb.ibp.aws.adapter.commom.dto.DeployeAppResponseDTO;
import com.bosicloud.cmb.ibp.aws.adapter.commom.dto.GetServiceInfoDTO;
import com.bosicloud.cmb.ibp.aws.adapter.service.DeployEcsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author Jack Peng / ziliang.peng@bosicloud.com
 */
@Slf4j
@RestController
@Api(value = "Deploye ECS Apps", description = "发布应用接口")
public class DeployeEcsController {

    @Autowired
    DeployEcsService deployEcsService;

    @ApiOperation(value = "创建基础环境")
    @PostMapping(value = UrlDefine.DEPLOY_APPS)
    public DeployeAppResponseDTO deployeApps(@RequestBody @Valid DeployeAppParamDTO param) {

        return deployEcsService.deployeApps(param);
    }

    @ApiOperation(value = "获取Service信息")
    @PostMapping(value = UrlDefine.GET_SERVICE_INFO)
    public List<Service> getServiceInfo(@RequestBody @Valid GetServiceInfoDTO param) {

        return deployEcsService.serviceInfo(param);
    }

}
